package com.tencreat.service.mall.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tencreat.common.core.domain.model.ReqStringParam;
import com.tencreat.domain.mall.MallOrder;
import com.tencreat.domain.mall.vo.ResIntegralMallOrderVO;
import com.tencreat.mapper.mall.MallOrderMapper;
import com.tencreat.service.mall.IIntegralMallOrderService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

/**
 * @author huang wei
 * @version 1.0
 * @date 2021/9/1 15:10
 * 积分
 */
//@Service
public class IntegralMallOrderServiceImpl extends ServiceImpl<MallOrderMapper, MallOrder> implements IIntegralMallOrderService {

    @Override
    public IPage<ResIntegralMallOrderVO> selectIntegralPage(ReqStringParam param) {
        QueryWrapper<?> queryWrapper=new QueryWrapper<>();
        queryWrapper.like(StringUtils.isNoneBlank(param.getCommon()),"mo.order_sn",param.getCommon());
        Page<ResIntegralMallOrderVO> page = baseMapper.selectIntegralPage(new Page<>(param.getPageNum(), param.getPageSize()), queryWrapper);
        return  page.convert(i -> {
            ResIntegralMallOrderVO result = new ResIntegralMallOrderVO();
            BeanUtils.copyProperties(i, result);
            return result;
        });
    }

}
